package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created by xiebang
 * Description
 * User:小谢
 * Date:2021-09-16
 * Time:11:02
 */
public class ReturnOperation implements IOperation {

    @Override
    public void work(BookList bookList) {
        System.out.println("返还图书！");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要归还的图书的名字：");
        String name = scanner.nextLine();
        int size = bookList.getUsedSize();
        for (int i = 0; i < size; i++) {
            Book book1 = bookList.getPos(i);
            if (book1.getName().equals(name)){
                book1.setBoroowed(false);
                System.out.println("归还成功");
                return;
            }
        }
        System.out.println("归还失败！");
    }
}


